<!--conf
<sample>
              <product version="1.5" edition="std"/>
                     <modifications>
                            <modified date="070101"/>
                     </modifications>
               </sample>
 --> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<title>Add / Delete items</title>

</head>

<body>
	
	
	<h1>Add / Delete items</h1>
	<p>You can freely customize a tree view. This sample illustrates that the tree items can be easily 
	added/deleted dynamically through the graphical user interface.
	You can insert new sibling or child node as well. 
	This feature allows you to configure a DHTML tree menu effortlessly.</p>
	
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link rel="stylesheet" type="text/css" href="../../../codebase/dhtmlx.css"/>
	<script src="../../../codebase/dhtmlx.js"></script>
	
	<script>
	
		function fixImage(id){
			switch(tree.getLevel(id)){
			case 1:
			tree.setItemImage2(id,'folderClosed.gif','folderOpen.gif','folderClosed.gif');
				break;
			case 2:
			tree.setItemImage2(id,'folderClosed.gif','folderOpen.gif','folderClosed.gif');			
				break;
			case 3:
			tree.setItemImage2(id,'folderClosed.gif','folderOpen.gif','folderClosed.gif');			
				break;			
			default:
			tree.setItemImage2(id,'leaf.gif','folderClosed.gif','folderOpen.gif');			
				break;
			}
		}
		
	</script>
	<table>
		<tr>
			<td valign="top">


				<div id="treeboxbox_tree" style="width:250px; height:218px;background-color:#f5f5f5;border :1px solid Silver;; overflow:auto;"></div>
			</td>
			<td rowspan="2" style="padding-left:25" valign="top">
			
			
			<a href="javascript:void(0);" onClick="var d=new Date(); tree.insertNewItem(tree.getSelectedItemId(),d.valueOf(),document.getElementById('ed1').value,0,0,0,0,'SELECT'); fixImage(d.valueOf());">Insert new child item</a> Item label <input type="text" value="New item" id="ed1"><br><br>
			
			<a href="javascript:void(0);" onClick="var d=new Date(); tree.insertNewNext(tree.getSelectedItemId(),d.valueOf(),document.getElementById('ed2').value,0,0,0,0,'SELECT'); fixImage(d.valueOf());">Insert new item next</a> Item label <input type="text" value="New item" id="ed2"><br><br>
			
			<a href="javascript:void(0);" onClick="tree.deleteItem(tree.getSelectedItemId(),true);">Delete item</a><br><br>
						
			</td>
		</tr>
		
	</table>

			
	
		<li>zeros passed to the function for arguments 4-7 (function to call on select, images) mean the usage of default values for them</li>
		<li>Last argument is a comma delimited string of the following possible value (upper case only):</li>
		<li type="circle">SELECT - move selection to this node after inserting</li>
		<li type="circle">CALL - call function on select</li>
		<li type="circle">TOP - add node to the top position </li>
		<li type="circle">CHILD - node has child items</li>
		<li type="circle">CHECKED - checkbox is checked (if exists)</li>
	<script>
			tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);

			tree.setSkin('dhx_skyblue');
			tree.setImagePath("../../../codebase/imgs/dhxtree_skyblue/");
			tree.loadXML("../common/tree.xml");


	</script>

</body>
</html>
